#import "dfhgwhruebvhrheyleatherfreight.h"
#import "dfhgwhruebvhrheycapableintellectual.h"
#define kListCount				5
#define kItemViewHeight			56
typedef NS_ENUM(NSInteger, PPP_PopSelectViewType) {
	PPP_PopSelectViewTypeNormal,
	PPP_PopSelectViewTypeRelation
};
@interface dfhgwhruebvhrheycapableintellectual ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UILabel *titleTextLabel;
@property (nonatomic, assign) PPP_PopSelectViewType popType;
@property (weak, nonatomic) IBOutlet UITableView *tabIV;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@end
@implementation dfhgwhruebvhrheycapableintellectual {
	NSArray<NSString *> *relationShips;
	void(^_relationShip)(NSString *relation);
	NSArray<dhgfywegwygeydwpursuitlaser *> *dataArray;
	void(^_callback)(dhgfywegwygeydwpursuitlaser *select);
}
- (void)awakeFromNib {
	[super awakeFromNib];
	self.php_w = dhgfywegwygeydwdispositionvisualize;
	self.tabIV.delegate = self;
	self.tabIV.dataSource = self;
	self.bgView.layer.cornerRadius = 10;
	self.bgView.layer.masksToBounds = YES;
	self.tabIV.separatorInset = UIEdgeInsetsZero;
	[self.tabIV registerClass:[UITableViewCell class] forCellReuseIdentifier:@"PPP_PopSelectCell"];
}
- (void)setPopTitle:(NSString *)popTitle {
	self.titleTextLabel.text = popTitle;
	_popTitle = popTitle;
}
- (void)bindPopData:(NSArray<dhgfywegwygeydwpursuitlaser *>*)list andSelect:(void(^)(dhgfywegwygeydwpursuitlaser *select))callback {
	_callback = callback;
	dataArray = list;
	self.popType = PPP_PopSelectViewTypeNormal;
	unsigned long min = MIN(kListCount, list.count);
	self.tabIV.scrollEnabled = list.count > kListCount;
	self.php_h = min * (kItemViewHeight + 1) + 112;
	self.center = dfhgwhruebvhrheyoptionsaving.keyWindow.center;
	[self.tabIV reloadData];
}
- (void)bindRelationShip:(NSArray<NSString *> *)list andSelect:(void(^)(NSString *relation))select {
	_relationShip = select;
	relationShips = list;
	self.popType = PPP_PopSelectViewTypeRelation;
	unsigned long min = MIN(kListCount, list.count);
	self.tabIV.scrollEnabled = list.count > kListCount;
	self.php_h = min * (kItemViewHeight + 1) + 112;
	self.center = dfhgwhruebvhrheyoptionsaving.keyWindow.center;
	[self.tabIV reloadData];
}
- (IBAction)cancelAction {
	switch (self.popType) {
		case PPP_PopSelectViewTypeNormal: {
			if (_callback) {
				_callback(nil);
			}
		}
			break;
		case PPP_PopSelectViewTypeRelation: {
			if (_relationShip) {
				_relationShip(nil);
			}
		}
		default:
			break;
	}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	switch (self.popType) {
		case PPP_PopSelectViewTypeNormal: {
			dhgfywegwygeydwpursuitlaser *item = dataArray[indexPath.row];
			if (_callback) {
				_callback(item);
			}
		}
			break;
		case PPP_PopSelectViewTypeRelation: {
			NSString *relation = relationShips[indexPath.row];
			if (_relationShip) {
				_relationShip(relation);
			}
		}
			break;
		default:
			break;
	}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
	return 56;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	return self.popType == PPP_PopSelectViewTypeNormal ? dataArray.count : relationShips.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PPP_PopSelectCell" forIndexPath:indexPath];
	cell.selectionStyle = UITableViewCellSelectionStyleNone;
	cell.textLabel.textAlignment = NSTextAlignmentCenter;
	cell.textLabel.textColor = @"#3B414B".dhgfywegwygeydwlearneddesignate;
	cell.textLabel.font = [UIFont regular:15];
	switch (self.popType) {
		case PPP_PopSelectViewTypeNormal: {
			cell.textLabel.text = dataArray[indexPath.row].title;
		}
			break;
		case PPP_PopSelectViewTypeRelation: {
			cell.textLabel.text = relationShips[indexPath.row];
		}
			break;
		default:
			break;
	}
	return cell;
}
@end
